﻿@model DingTalkAgent.Web.Models.SysP_Page
@{
    ViewBag.Title = "PopupSysPList";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="modal-header">
    <h4 class="modal-title">选择上级页面</h4>
</div>

<div class="modal-body">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox ">
                    <div class="ibox-title">
                    </div>
                    <div class="ibox-content">
                        <form role="form" class="form-inline" id="form1" name="form1">
                            <div class="form-group">
                                <label for="exampleInputEmail2" class="sr-only">关键字</label>
                                <input type="email" placeholder="请输入关键字" id="keyword" name="keyword" class="form-control">
                            </div>
                            <button class="btn btn-white" type="button" id="btnsearch">查询</button>
                        </form>
                    </div>
                    <div class="ibox-content">
                        <div class="jqGrid_wrapper">
                            <table id="table_list_1"></table>
                            <div id="pager_list_1"></div>
                        </div>
                        <p>&nbsp;</p>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">

    $(document).ready(function () {
        $("#btnsearch").click(function () {
            $("#table_list_1").jqGrid('setGridParam', {
                postData: $('#form1').serializeObject(),
                page: 1
            }).trigger("reloadGrid"); //重新载入
        });

        $.jgrid.defaults.styleUI = 'Bootstrap';
        var grid = $("#table_list_1");
        $("#table_list_1").jqGrid({
            url: '/SysBase/SysPList',
            datatype: "json",
            mtype: 'POST',
            height: 'auto',
            autowidth: true,
            shrinkToFit: true,
            multiselect: true,
            multiboxonly: true,
            postData:$('#form1').serializeObject(),
            cellEdit: true,
            rowNum: 10,
            rowList: [10, 20, 30],
            colNames: ['Page_ID', '页面代码', '页名字', '上层页面', 'Controller', 'Action'],
            colModel: [
                {
                    name: 'Page_ID',
                    index: 'Page_ID',
                    width: '15%',
                },
                {
                    name: 'Code',
                    index: 'Code',
                    width: '15%',
                },
                {
                    name: 'Name',
                    index: 'Name',
                    width: '15%',
                },
                {
                    name: 'Parent_ID',
                    index: 'Parent_ID',
                    width: '15%',
                },
                {
                    name: 'Controller',
                    index: 'Controller',
                    width: '20%',
                },
                {
                    name: 'Action',
                    index: 'Action',
                    width: '20%',
                },
            ],
            jsonReader: {
                root: "List",
                page: "page",
                total: "total",
                records: "records",
                repeatitems: false,
            },
            pager: "#pager_list_1",
            viewrecords: true,
            hidegrid: false,
            onSelectRow: function (rowId, status) {
                //alert(JSON.stringify($("#table_list_1").jqGrid('getRowData', rowId)));
                var arrRow = $("#table_list_1").jqGrid('getRowData', rowId);
                window.parent.changeParentPage(arrRow['Page_ID'], arrRow['Name'], arrRow['Code']);
            },
            loadComplete: function () {
                var cbs = $("tr.jqgrow > td > input.cbox", grid[0]);
                cbs.attr("style", "display:none");
                $("#cb_table_list_1").attr("style", "display:none");
            },

        });
        // Add responsive to jqGrid
        $(window).bind('resize', function () {
            var width = $('.jqGrid_wrapper').width();
            $('#table_list_1').setGridWidth(width);
        });
        $('#mmXgmodal').on('hidden.bs.modal', function () {
            $(this).removeData('bs.modal');
        });

    });

</script>



